package org.linlinjava.litemall.admin.web.order_manage;

import org.linlinjava.litemall.admin.service.order_manage.AgedmallVipService;
import org.linlinjava.litemall.admin.vo.vip.AddVipLevelVo;
import org.linlinjava.litemall.admin.vo.vip.ModifyUserVipLevelVo;
import org.linlinjava.litemall.admin.vo.vip.VipLevelListVo;
import org.linlinjava.litemall.admin.vo.vip.VipUserListVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author wj
 * @date 2022/1/27 14:17
 */
@RestController
@RequestMapping("/vip")
public class AgedmallVipController {


    @Resource
    private AgedmallVipService agedmallVipService;


    /**
     * 新增vip等级
     */
    @RequestMapping("/addVipLevel")
    public Object addVipLevel(@RequestBody AddVipLevelVo addVipLevelVo){


        return agedmallVipService.addVipLevel(addVipLevelVo);
    }


    /**
     * 修改vip等级/修改vip状态
     */
    @RequestMapping("/modifyVipLevel")
    public Object modifyVipLevel(@RequestBody @Validated AddVipLevelVo addVipLevelVo){

        return agedmallVipService.modifyVipLevel(addVipLevelVo);
    }


    /**
     * 获取vip等级列表
     */
    @RequestMapping("/vipLevelList")
    public Object vipLevelList(@RequestBody @Validated VipLevelListVo vipLevelListVo){
        return agedmallVipService.vipLevelList(vipLevelListVo);
    }



    //--------vip会员管理---------------

    /**
     * 根据手机号码获取用户信息
     */
    @RequestMapping("/searchVipUserByPhone/{phone}")
    public Object searchVipUserByPhone(@PathVariable @Validated @NotBlank(message = "手机号码不能为空") String phone){
        return agedmallVipService.searchVipUserByPhone(phone);
    }


    /**
     * 修改用户等级
     */
    @RequestMapping("/modifyUserVipLevel")
    public Object modifyUserVipLevel(@RequestBody @Validated ModifyUserVipLevelVo modifyUserVipLevelVo){
        return agedmallVipService.modifyUserVipLevel(modifyUserVipLevelVo);
    }

    /**
     * 会员用户列表
     */
    @RequestMapping("/vipUserList")
    public Object vipUserList(@RequestBody @Validated VipUserListVo vipUserListVo){
        return agedmallVipService.vipUserList(vipUserListVo);
    }

    /**
     * 删除vip会员
     */
    @RequestMapping("/deleteVipUser/{id}")
    public Object deleteVipUser(@PathVariable @Validated @NotNull(message = "id不能为空")Integer id){
        return agedmallVipService.deleteVipUser(id);
    }

}
